#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <gmp.h>
#include <time.h>

/* 4 bits words are padded to 8 bits words */

#define SIZE_4 1
#define WORDS_4_BITS 8
/* NAILS is the number of padding bits for each word */
#define NAILS 4
#define RAND_MOD 2047
#define BASE 2
#define ORDER 1
#define ENDIAN 0

void Product4(void *a, void *b, void *c, size_t *sa, size_t *sb, size_t *sc){

    mpz_t x,y,z;
    mpz_init(x);
    mpz_init(y);
    mpz_init(z); 

    /* Cast a and b into short integers of size 8 bits */
    unsigned char *cint_a = (unsigned char *) a;
    unsigned char *cint_b = (unsigned char *) b;

    /* Now cint_a can be view as an array of words of size 8 bits 
     * with 4 padded bits in each words.
     * Similarly for int_b 
    */

    printf("%d %d \n", cint_a[0], cint_a[*sa - 1]);
    printf("%d %d \n", cint_b[0], cint_b[*sb - 1]);

    mpz_import(x, *sa, ORDER, SIZE_4, ENDIAN, NAILS, a);
    mpz_import(y, *sb, ORDER, SIZE_4, ENDIAN, NAILS, b);
    mpz_mul(z,x,y);
    c = mpz_export(c, sc, ORDER, SIZE_4, ENDIAN, NAILS, z);
}

